//
//  DDContactRefusedCell.m
//  DingDongZP
//
//  Created by 杨政涛 on 16/6/28.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

#import "DDContactRefusedCell.h"
#import "DDContactRequestMessage.h"

@interface DDContactRefusedCell ()

@property (nonatomic, strong) UILabel *contentLab;


@end

@implementation DDContactRefusedCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        self.contentLab = [[UILabel alloc] initWithFrame:CGRectZero];
        self.contentLab.backgroundColor = [UIColor colorWithWhite:.8 alpha:0.5];
        self.contentLab.layer.cornerRadius = 4.0;
        self.contentLab.layer.masksToBounds = YES;
        self.contentLab.textAlignment = NSTextAlignmentCenter;
        self.contentLab.textColor = COLOR_FONT_DARK_GRAY;
        self.contentLab.font = [UIFont systemFontOfSize:14.0];
        [self.contentView addSubview:self.contentLab];
    }
    return self;
}


- (void)setDataModel:(RCMessageModel *)model
{
    [super setDataModel:model];
    if ([model.content isKindOfClass:[DDContactRequestMessage class]])
    {
        DDContactRequestMessage *message = (DDContactRequestMessage*)model.content;
        NSString *content = nil;
        NSString *typename = nil;
        if (message.requestType == DDContactRequestPhone) {
            typename = @"电话";
        }
        else {
            typename = @"微信";
        }
        
        if (model.messageDirection == MessageDirection_SEND) {
             content = @"您已拒绝交换";  // 主动显示
        }
        else {
             content = @"对方已拒绝交换"; // 对方接收到的信息
        }
        self.contentLab.text = [NSString stringWithFormat:@"%@%@",content,typename];
    }
}



- (void)layoutSubviews
{
    [super layoutSubviews];
    self.contentLab.frame = CGRectMake(20, 0, 150, 20);
    self.contentLab.centerX = CGRectGetMidX(self.bounds);
    self.contentLab.center = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
    
    UIView *portrait = (UIView *)self.portraitImageView;
    portrait.hidden = YES;
    [self.messageTimeLabel removeFromSuperview];
}


/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */
@end
